********************************************************************************
* appendix figure 5: maps of near-far samples in portland and brooklyn

********************************************************************************

cd "$main_dir/data"

* portland

* subset listings in near far sample
use near_far_m600_i250_g,clear
keep if msa=="portland"

gen treated=(dist<250)
gen control=(dist<600)
keep if treated==1 | control==1
keep if building_sample==1 &  tx250_min_number>0 & tx256_min_number>0 
rename (listing_lat listing_lon) (final_lat final_lon)

save apts,replace

* load zip shape file and merge to characteristics
use cleaned_zip_db,clear
rename zcta5 zip
merge 1:1 zip using zips_2016
keep if _merge==3

* subset portland zips
keep if floor(zip/100)==972

spmap med_hh_inc_2016 using zip_co, id(_ID) ocolor(black) osize(vvvthin vvvthin vvvthin vvvthin) ///
	fcolor(Blues)  clmethod(custom) clbreaks(0 30000 60000 90000 1000000) ///
	point(data("apts.dta") by(treated) ///
	x(final_lon) y(final_lat) size(0.6 0.6) fcolor(none none) ocolor(black red) osize(vthin vthin) ///
	legenda(on) ) ///
	legend(position(2)) ///
	legtitle("Median Household Income") legstyle(2)	

***********************

* brooklyn

* subset listings in near far sample
use near_far_m600_i250_g,clear
keep if msa=="brooklyn"

gen treated=(dist<250)
gen control=(dist<600)
keep if treated==1 | control==1
keep if building_sample==1 &  tx250_min_number>0 & tx256_min_number>0 
rename (listing_lat listing_lon) (final_lat final_lon)

save apts,replace

* load zip shape file and merge to characteristics
use cleaned_zip_db,clear
rename zcta5 zip
merge 1:1 zip using zips_2016
keep if _merge==3

* subset brooklyn zips
keep if state_2016==36 & county_2016==047

spmap med_hh_inc_2016 using zip_co, id(_ID) ocolor(black) osize(vvvthin vvvthin vvvthin vvvthin) ///
	fcolor(Blues)  clmethod(custom) clbreaks(0 30000 60000 90000 1000000) ///
	point(data("apts.dta") by(treated) ///
	x(final_lon) y(final_lat) size(0.6 0.6) fcolor(none none) ocolor(black red) osize(vthin vthin) ///
	legenda(on) ) ///
	legend(position(2)) ///
	legtitle("Median Household Income") legstyle(2)	
	
